﻿using System.Collections;
using System.Collections.Generic;
using TTGameEngine;
using UnityEngine;
namespace AliveCard {
/// <summary>
/// 房间有状态：
/// 已解锁
///     玩家是否可以点击前往
///
/// 已探索
///     房间是否蒙黑
///
/// </summary>
public class Room : MonoBehaviour {
    [Tooltip("Idx从0开始。序号必须连续。")]
    public int m_roomIdx = 0;
    public Transform m_standPos;
    public GameObject m_blackCover;
    public GameObject m_wallLB;
    public GameObject m_wallRB;

    public RoomTriggerDetector m_triggerDetector;

    [SerializeField, ReadOnly, Tooltip("已探索，不蒙黑")]
    bool isExplored = false;
    [SerializeField, ReadOnly, Tooltip("锁住，不可前往")]
    bool isLock = true;

    public bool IsLock {
        get { return isLock; }
        set { isLock = value; }
    }

    public bool IsExplored {
        get { return isExplored; }
    }

    // Use this for initialization
    void Start() {
        if(isExplored) {
            m_blackCover.SetActive(false);
        }
        gameObject.name = "Room - " + m_roomIdx;
    }

    // Update is called once per frame
    void Update() {

    }

//         public void OnClickRoom()
//         {
//             RoomManager.Ins.MoveToRoom(this);
//         }
//
//         public void ClickRoom()
//         {
//
//         }

    public void OnEnterRoom(ACPuppet p) {
        Explored();
        RoomManager.Ins.OnEnterRoom(this, p);
    }

    public void OnExitRoom(ACPuppet p) {
        RoomManager.Ins.OnExitRoom(this, p);
    }

    void Explored() {
        isExplored = true;
        m_blackCover.SetActive(false);
    }

    public void SetupLayer(bool isWallLB, bool isWallRB) {
        m_wallLB.SetActive(isWallLB);
        m_wallRB.SetActive(isWallRB);
    }

    public void ActiveRoomTrigger(bool b) {
        m_triggerDetector.IsEnable = b;
    }
}
}